package com.sw.study.springmvc.demo.controller;

import com.sw.study.springmvc.annotation.SwController;
import com.sw.study.springmvc.annotation.SwRequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by sw on 2020/4/18.
 * 无权限拦截的类
 */

@SwController
@SwRequestMapping("/noSecurity")
public class NoSecurityController {
    /**
     * 无权限拦截
     * @param username
     */
    @SwRequestMapping("/init")
    public void init(HttpServletRequest request, HttpServletResponse response, String username){
        System.out.println("im no security:"+username);
        try {
            request.setCharacterEncoding("UTF-8");
            response.setContentType("text/html;charset=utf-8");
            response.getWriter().write(username+"---->无权限拦截");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}